<?php include_component('includes','submenu') ?>
<?php $myLib=new myLib(); ?>
<?php //echo md5('opinics').' - o13d8cf52d710c14da05ff0043bbe6e16s' ?>
<fieldset style="background-color: white;">
<div style="float: left;width: 670px;min-height: 200px;">
  <div style="padding: 10px;">
    <?php include_component('includes','miniSearch') ?>
  <?php $articles = $sf_data->getRaw('articles'); ?>
  <?php $c = 0; ?>
  <?php foreach($articles as $article){ ?>
    <?php if($c==0){ /* primer resultado */ ?>
    <div class="articulo background_body">
      <div class="articulo_izq">
        <div class="abbr_date">
          <div style="padding: 9px;">
            <?php echo $myLib->formattedDateAbbr($article->getCreatedAt(),$sf_user->getCulture()); ?>
          </div>
        </div>
        <div style="padding: 10px;">
          <?php echo image_tag('/uploads/author/'.$article->getOwnerId().'.jpg','size=100x100') ?>
        </div>
      </div>
      <div class="articulo_der">
          <div class="sup" style="width: 100%;height: 20px;margin: 20px 0;">
            <div style="width: 300px;float: left;">
              <?php echo $article->getCategory()->getDescription().' / '.$article->getSubcategory()->getDescription() ?>
            </div>
            <div style="width: 20px;float: left;">
                <?php echo $comments_count[$article->getId()] ?>
            </div>
            <div style="width: 30px;float: left;">
                <?php echo image_tag('comentario.png') ?>
            </div>
            <div style="width: 50px;float: left;">
                Rating:
            </div>
            <div style="width: 100px;float: left;">
                <?php for($j=1;$j<=5;$j++){ ?>
                  <?php if($j<=round($article->getScore())){ ?>
                    <?php echo image_tag('estrella_on.png') ?>
                  <?php }else{ ?>
                    <?php echo image_tag('estrella.png') ?>
                  <?php } ?>
                <?php } ?>
            </div>
          </div>
          <div class="inf" style="margin-bottom: 10px;">
            <div style="margin-bottom: 5px;text-align: justify;">
                <a href="<?php echo url_for('@article?id='.$article->getId().'&slug='.$article->getSlug()) ?>">
                    <h1><?php echo $article->getTitle() ?></h1></a>
            </div>
            <div style="text-align: justify;color: #6D6C67;">
                <?php echo substr($article->getSummary(),0,500) ?> ...
            </div>
              <br />
            <div>
                Autor: <a href="<?php echo url_for('@profile?id='.$article->getOwnerId()) ?>">
                  <b>
                  <?php if(count($array_users)>0){ ?>
                    <?php foreach($array_users as $key => $practil_user){ ?>
                      <?php if($practil_user->{'id'} == $article->getAccount()->getPractilAccountId()){ ?>
                        <?php echo $array_users[$key]->{'name'}.' '.$array_users[$key]->{'lastName'}; ?>
                      <?php } ?>
                    <?php } ?>
                  <?php }else{ ?>
                    <?php echo 'Autor Nombre Completo' ?>
                  <?php } ?>
                  </b>
                </a>
            </div>
          </div>
      </div>
    </div>
      <hr />
    <?php }elseif($c==1){ ?>
    <div class="articulo background_body">
      <div class="articulo_izq">
        <div style="padding: 10px;">
          <?php echo image_tag('/uploads/author/'.$article->getOwnerId().'.jpg','size=100x100') ?>
        </div>
      </div>
      <div class="articulo_der">
          <div class="sup" style="width: 100%;height: 20px;float: left;margin: 20px 0;">
            <div style="width: 300px;float: left;">
              <?php echo $article->getCategory()->getDescription().' / '.$article->getSubcategory()->getDescription() ?>
            </div>
            <div style="width: 20px;float: left;">
                <?php echo $comments_count[$article->getId()] ?>
            </div>
            <div style="width: 30px;float: left;">
                <?php echo image_tag('comentario.png') ?>
            </div>
            <div style="width: 50px;float: left;">
                Rating:
            </div>
            <div style="width: 100px;float: left;">
                <?php for($j=1;$j<=5;$j++){ ?>
                  <?php if($j<=round($article->getScore())){ ?>
                    <?php echo image_tag('estrella_on.png') ?>
                  <?php }else{ ?>
                    <?php echo image_tag('estrella.png') ?>
                  <?php } ?>
                <?php } ?>
            </div>
          </div>
          <div class="inf" style="margin-bottom: 10px;">
            <div style="margin-bottom: 5px;text-align: justify;">
                <a href="<?php echo url_for('@article?id='.$article->getId().'&slug='.$article->getSlug()) ?>">
                  <h2><?php echo $article->getTitle() ?></h2></a>
            </div>
            <div style="text-align: justify;color: #6D6C67;">
                <?php echo substr($article->getSummary(),0,200) ?> ...
            </div>
              <br />
            <div>
                Autor: <a href="<?php echo url_for('@author?id='.$article->getOwnerId()) ?>">
                  <b>
                  <?php if(count($array_users)>0){ ?>
                    <?php foreach($array_users as $key => $practil_user){ ?>
                      <?php if($practil_user->{'id'} == $article->getAccount()->getPractilAccountId()){ ?>
                        <?php echo $array_users[$key]->{'name'}.' '.$array_users[$key]->{'lastName'}; ?>
                      <?php } ?>
                    <?php } ?>
                  <?php }else{ ?>
                    <?php echo 'Autor Nombre Completo' ?>
                  <?php } ?>
                  </b>
                </a>
            </div>
          </div>
      </div>
    </div>
    <?php }else{ ?>
    <div class="articulo background_body">
      <div class="articulo_izq">
        <div style="text-align: center;margin-top: 25px;">
          <?php echo image_tag('/uploads/author/'.$article->getOwnerId().'.jpg','size=50x50') ?>
        </div>
      </div>
      <div class="articulo_der">
          <div class="inf" style="margin-bottom: 10px;">
            <div style="margin-bottom: 5px;text-align: justify;">
                <a href="<?php echo url_for('@article?id='.$article->getId().'&slug='.$article->getSlug()) ?>">
                  <h3><?php echo $article->getTitle() ?></h3></a>
            </div>
            <div style="text-align: justify;color: #6D6C67;">
                <?php echo substr($article->getSummary(),0,80) ?> ...
            </div>
              <br />
            <div>
                Autor: <a href="<?php echo url_for('@author?id='.$article->getOwnerId()) ?>">
                  <b>
                  <?php if(count($array_users)>0){ ?>
                    <?php foreach($array_users as $key => $practil_user){ ?>
                      <?php if($practil_user->{'id'} == $article->getAccount()->getPractilAccountId()){ ?>
                        <?php echo $array_users[$key]->{'name'}.' '.$array_users[$key]->{'lastName'}; ?>
                      <?php } ?>
                    <?php } ?>
                  <?php }else{ ?>
                    <?php echo 'Autor Nombre Completo' ?>
                  <?php } ?>
                  </b>
                </a>
            </div>
          </div>
      </div>
    </div>
    <?php } ?>
<?php $c++; ?>
  <?php } ?>
  </div>
</div>
<div style="float: left;width: 320px;">
  <?php include_component('includes','autores') ?>
  <?php include_component('includes','destacados') ?>
</div>
</fieldset>
<script type="text/javascript">
$(document).ready(function(){
  <?php if(is_object($subcategory)){ ?>
    if('<?php echo $subcategory->getId() ?>'!=''){
        loadSubcategories2('<?php echo $subcategory->getCategory()->getId() ?>',
        function(){
            $("#subcategoria_<?php echo $subcategory->getId() ?>").addClass('selected')
        }
    );
    }
  <?php } ?>
});
</script>